package com.stu.aq;

import android.annotation.SuppressLint;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;

/*
 * StatusManager runs on the UI thread
 */
public class StatusManager {
	private Handler h;
	
	@SuppressLint("HandlerLeak")
	public StatusManager() {
		h = new Handler( Looper.getMainLooper() ) {
			@Override
			public void handleMessage(Message msg) {
				StatusData st = (StatusData)msg.obj;
				CommandFragment f = st.fragment.get();
				if( f != null )
					f.updateUI( st.data );
			}
			
		};
	}
	
	public void handleState( StatusData s ) {
		Message m = h.obtainMessage(0, s);
		m.sendToTarget();
	}
}
